package com.jsgt.greekfire.ui.mine.purse

import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.graphics.Bitmap
import com.fhx.core.base.BaseActivity
import com.fhx.core.utils.QRCodeUtils
import com.fhx.core.utils.ScreenUtil
import com.jsgt.greekfire.R
import com.jsgt.greekfire.common.util.NetDataManager
import kotlinx.android.synthetic.main.activity_miners_purse.*


class MinersPurseActivity : BaseActivity() {

    private var codeBitmap: Bitmap? = null

    override fun getLayoutId(): Int = R.layout.activity_miners_purse

    override fun main() {
        showTitleView()
        title = getString(R.string.miners_purse)


        val info = NetDataManager.walletInfo ?: return

        miners_nickname.text = info.walletName
        wallet_address.text = "${info.utiAddress}"


        val height = ScreenUtil.dip2px(this, 200f).toInt()
        codeBitmap = QRCodeUtils.createQRCodeBitmap(info.utiAddress, height, height)
        miners_code_iv.setImageBitmap(codeBitmap)

        miners_purse_sure.setOnClickListener {
            //获取系统剪贴板
            val cm = this.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
            val mClipData = ClipData.newPlainText("Label", wallet_address.text.toString())
            cm.setPrimaryClip(mClipData)
            showToast("复制成功")
        }
    }

}